package service

import (
	"guliedu/model"
	"guliedu/repository"
	"mime/multipart"
)

type ICrmBannerService interface {
	Insert(banner *model.CrmBanner) error
	UploadBanner(file multipart.File, fileSize int64) (string, int)
	GetBannerListPage(page int, pageSize int) ([]model.CrmBanner, error)
	SelectCount() (int64, error)
	Select(id string) (*model.CrmBanner, error)
	Update(banner *model.CrmBanner) error
	Delete(id string) error
	SelectAll() ([]model.CrmBanner, error)
	CacheBanner(banners []model.CrmBanner) error
	GetCacheBanner() []model.CrmBanner
}

func NewICrmBannerService() ICrmBannerService {
	return &CrmBannerService{CrmBannerRepository: repository.NewICrmBannerRepository()}
}

type CrmBannerService struct {
	CrmBannerRepository repository.ICrmBannerRepository
}

func (t *CrmBannerService) Insert(banner *model.CrmBanner) error {
	return t.CrmBannerRepository.Insert(banner)
}

func (t *CrmBannerService) UploadBanner(file multipart.File, fileSize int64) (string, int) {
	return t.CrmBannerRepository.UploadBanner(file, fileSize)
}

func (t *CrmBannerService) GetBannerListPage(page int, pageSize int) ([]model.CrmBanner, error) {
	return t.CrmBannerRepository.GetBannerListPage(page, pageSize)
}

func (t *CrmBannerService) SelectCount() (int64, error) {
	return t.CrmBannerRepository.SelectCount()
}

func (t *CrmBannerService) Select(id string) (*model.CrmBanner, error) {
	return t.CrmBannerRepository.Select(id)
}

func (t *CrmBannerService) Delete(id string) error {
	return t.CrmBannerRepository.Delete(id)
}

func (t *CrmBannerService) Update(banner *model.CrmBanner) error {
	return t.CrmBannerRepository.Update(banner)
}

func (t *CrmBannerService) SelectAll() ([]model.CrmBanner, error) {
	return t.CrmBannerRepository.SelectAll()
}

func (t *CrmBannerService) CacheBanner(banners []model.CrmBanner) error {
	return t.CrmBannerRepository.CacheBanner(banners)
}

func (t *CrmBannerService) GetCacheBanner() []model.CrmBanner {
	return t.CrmBannerRepository.GetCacheBanner()
}
